import { useRoutes, Navigate } from "react-router-dom"
import router from './router'
import { getToken } from './utils/auth'
import Login from './pages/Login'

const App = () => {
	const token = getToken()
	let routers = [
		{
			path: '/login',
			element: <Login/>
		},
		{
			path: '*',
			element: <Navigate to='/login' />
		}
	]
	if (token) {
		routers = router
	}
	const outlet = useRoutes(routers)
	return (
		<>
			{outlet}
		</>
	)
};
export default App
